﻿using FBroSharp.Callback;
using FBroSharp.Const;
using FBroSharp.DataType;
using FBroSharp.Event;
using FBroSharp.Lib;
using FBroSharp.Value;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;

namespace JS交互测试
{
    public class FBroQueryHandlerDis : FBroSharpQueryHandler
    {
        public int type_;
        public FBroQueryHandlerDis(int type)
        {
            type_ = type;
        }

        public override bool OnQuery(IFBroSharpBrowser browser, IFBroSharpFrame frame, long query_id, string request, bool persistent, IFBroSharpQueryCallback callback)
        {
            Console.WriteLine(MethodBase.GetCurrentMethod().Name);

            switch (type_)
            {
                case 0:
                    callback.Success("执行成功" + request);
                    break;
                case 1:
                    callback.Failure(111, "执行失败" + request);
                    break;
            }

            return true;
        }

        public override void OnQueryCanceled(IFBroSharpBrowser browser, IFBroSharpFrame frame, long query_id)
        {
            Console.WriteLine(MethodBase.GetCurrentMethod().Name + query_id);

        }
    }

}
